package com.nail.api.customMake.dao;

import com.nail.api.customMake.bean.Template;
import com.nail.dao.IBaseDao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ITemplateDao extends IBaseDao<Template> {

    @Select("select count(1) as num from template where template_type = #{templateType}")
    public Integer getTemplateCount(@Param("templateType")String templateType);

    @Select("select * from template where template_type = #{templateType} order by is_sort desc,create_time desc limit #{start},#{end}")
    public List<Template> getTemplate(@Param("templateType")String templateType, @Param("start")Integer start, @Param("end")Integer end);


    @Select("select count(1) as num from template")
    public Integer getTemplateCountAll();

    @Select("select * from template order by is_sort desc,create_time desc limit #{start},#{end}")
    public List<Template> getTemplateAll(@Param("start") Integer start, @Param("end")Integer end);

    @Select("select * from template where id = #{id} and user_id = #{userId}")
    public Template getTemplateByIdAndUserId(@Param("userId")Long userId,@Param("id")Long id);

    @Update("update template set is_sort = #{sort} where id = #{id}")
    public void setSort(@Param("id") Long id,@Param("sort") Integer sort);

    @Update("update template set is_able = #{isAble} where id = #{id}")
    public void setIsAble(@Param("id") Long id,@Param("isAble") Integer isAble);
}
